{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "44bc1081",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os \n",
    "import json\n",
    "from dotenv import load_dotenv\n",
    "from IPython.display import display, HTML, Markdown\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "0b470bdf",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "OpenAI API Key not set\n",
      "Anthropic API Key not set (and this is optional)\n",
      "Google API Key exists and begins AI\n",
      "DeepSeek API Key not set (and this is optional)\n",
      "Groq API Key exists and begins gsk_\n"
     ]
    }
   ],
   "source": [
    "#Print the key prefixes to help with any debugging\n",
    "\n",
    "openai_api_key = os.getenv('OPENAI_API_KEY')\n",
    "anthropic_api_key = os.getenv('ANTHROPIC_API_KEY')\n",
    "google_api_key = os.getenv('GOOGLE_API_KEY')\n",
    "deepseek_api_key = os.getenv('DEEPSEEK_API_KEY')\n",
    "groq_api_key = os.getenv('GROQ_API_KEY')\n",
    "\n",
    "if openai_api_key:\n",
    "    print(f\"OpenAI API Key exists and begins {openai_api_key[:8]}\")\n",
    "else:\n",
    "    print(\"OpenAI API Key not set\")\n",
    "    \n",
    "if anthropic_api_key:\n",
    "    print(f\"Anthropic API Key exists and begins {anthropic_api_key[:7]}\")\n",
    "else:\n",
    "    print(\"Anthropic API Key not set (and this is optional)\")\n",
    "\n",
    "if google_api_key:\n",
    "    print(f\"Google API Key exists and begins {google_api_key[:2]}\")\n",
    "else:\n",
    "    print(\"Google API Key not set (and this is optional)\")\n",
    "\n",
    "if deepseek_api_key:\n",
    "    print(f\"DeepSeek API Key exists and begins {deepseek_api_key[:3]}\")\n",
    "else:\n",
    "    print(\"DeepSeek API Key not set (and this is optional)\")\n",
    "\n",
    "if groq_api_key:\n",
    "    print(f\"Groq API Key exists and begins {groq_api_key[:4]}\")\n",
    "else:\n",
    "    print(\"Groq API Key not set (and this is optional)\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "8b135e11",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "load_dotenv()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "52d9fbc6",
   "metadata": {},
   "outputs": [],
   "source": [
    "google_api_key = os.getenv('GOOGLE_API_KEY')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "a9711dd9",
   "metadata": {},
   "outputs": [],
   "source": [
    "request = \"Please reasearch the Top 5 Agentic AI frameworks and list them in a numbered list with a one sentence description of each.\" \\\n",
    "     \"your evaluation should be based on their popularity, features, ease of use, and community support. \" \\\n",
    "     \" After listing them, please provide a brief comparison highlighting the strengths and weaknesses of each framework.\"\n",
    "request += \"Answer only with the question, no explanation.\"\n",
    "messages = [{\"role\": \"user\", \"content\": request}]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "85386a35",
   "metadata": {},
   "outputs": [],
   "source": [
    "from openai import OpenAI\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "02fb57c1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'role': 'user',\n",
       "  'content': 'Please reasearch the Top 5 Agentic AI frameworks and list them in a numbered list with a one sentence description of each.your evaluation should be based on their popularity, features, ease of use, and community support.  After listing them, please provide a brief comparison highlighting the strengths and weaknesses of each framework.Answer only with the question, no explanation.'}]"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "messages"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "51ac88a2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.  **LangChain**: A comprehensive framework for developing applications powered by large language models, offering modular components including robust agent creation capabilities with tools, memory, and chains.\n",
      "2.  **AutoGen**: A Microsoft-developed framework enabling the development of multi-agent conversation systems where agents can converse with each other and humans to solve tasks collaboratively.\n",
      "3.  **CrewAI**: A framework specifically designed for orchestrating sophisticated multi-agent systems where agents, equipped with distinct roles and tools, collaborate to execute complex tasks sequentially or in parallel.\n",
      "4.  **LlamaIndex**: A data framework that integrates LLMs with external data, providing tools for indexing, retrieval, and agents to intelligently query and interact with various data sources.\n",
      "5.  **SuperAGI**: An open-source autonomous AI agent framework designed to enable developers to build, manage, and deploy goal-driven AI agents with persistent memory and tool use.\n",
      "\n",
      "**Comparison:**\n",
      "\n",
      "*   **LangChain**:\n",
      "    *   **Strengths**: Extremely versatile with extensive features for various LLM applications, massive community support, highly modular for custom solutions.\n",
      "    *   **Weaknesses**: Can have a steep learning curve due to its breadth, potentially complex for simpler agent tasks, documentation can be overwhelming.\n",
      "*   **AutoGen**:\n",
      "    *   **Strengths**: Excellent for multi-agent collaboration and human-in-the-loop systems, highly flexible agent configurations, strong performance and backed by Microsoft.\n",
      "    *   **Weaknesses**: Primarily focused on conversational agents, might be overkill for single-agent tasks, ecosystem of specific tools is still maturing compared to broader frameworks.\n",
      "*   **CrewAI**:\n",
      "    *   **Strengths**: Intuitive for defining agent roles and complex collaborative workflows, strong emphasis on structured task delegation, promotes clear and organized multi-agent systems.\n",
      "    *   **Weaknesses**: More specialized towards multi-agent collaboration, potentially less flexible for highly custom or non-collaborative agent architectures, a newer framework with a rapidly growing but still smaller community.\n",
      "*   **LlamaIndex**:\n",
      "    *   **Strengths**: Exceptional for Retrieval Augmented Generation (RAG) and data-centric agents, simplifies interaction with complex and varied data sources, integrates well with other LLM frameworks.\n",
      "    *   **Weaknesses**: Agentic capabilities are often centered around data retrieval and interaction, not as broad for general-purpose or autonomous agent tasks as other dedicated agent frameworks.\n",
      "*   **SuperAGI**:\n",
      "    *   **Strengths**: Dedicated to building and managing autonomous, goal-oriented agents, offers a user interface for agent deployment and monitoring, strong focus on persistent memory and advanced tool integration for long-running tasks.\n",
      "    *   **Weaknesses**: Smaller community compared to leading frameworks, the ecosystem of specialized tools and integrations is less vast, can be complex to debug autonomous loops without robust internal tooling.\n"
     ]
    }
   ],
   "source": [
    "openai = OpenAI(api_key=google_api_key, base_url=\"https://generativelanguage.googleapis.com/v1beta/openai/\")\n",
    "response = openai.chat.completions.create(\n",
    "    model=\"gemini-2.5-flash\",\n",
    "    messages=messages,\n",
    ")\n",
    "question = response.choices[0].message.content\n",
    "print(question)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "5a9bfdfc",
   "metadata": {},
   "outputs": [],
   "source": [
    "teammates = []\n",
    "answers = []\n",
    "messages = [{\"role\": \"user\", \"content\": question}]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2cd38d05",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Anthropic has a slightly different API, and Max Tokens is required\n",
    "\n",
    "model_name = \"claude-3-7-sonnet-latest\"\n",
    "\n",
    "claude = Anthropic()\n",
    "response = claude.messages.create(model=model_name, messages=messages, max_tokens=1000)\n",
    "answer = response.content[0].text\n",
    "\n",
    "display(Markdown(answer))\n",
    "teammates.append(model_name)\n",
    "answers.append(answer)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9473c5f4",
   "metadata": {},
   "outputs": [],
   "source": [
    "deepseek = OpenAI(api_key=deepseek_api_key, base_url=\"https://api.deepseek.com/v1\")\n",
    "model_name = \"deepseek-chat\"\n",
    "\n",
    "response = deepseek.chat.completions.create(model=model_name, messages=messages)\n",
    "answer = response.choices[0].message.content\n",
    "\n",
    "display(Markdown(answer))\n",
    "teammates.append(model_name)\n",
    "answers.append(answer)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "c8773635",
   "metadata": {},
   "outputs": [],
   "source": [
    "from groq import Groq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "822f224a",
   "metadata": {},
   "outputs": [],
   "source": [
    "groq_api_key = os.getenv('GROQ_API_KEY')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "ee867fc0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "load_dotenv()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "438fc697",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "The provided information presents a comprehensive comparison of five frameworks: LangChain, AutoGen, CrewAI, LlamaIndex, and SuperAGI. Each framework has its unique strengths and weaknesses, which are discussed below:\n",
       "\n",
       "### LangChain\n",
       "- **Strengths:** Highly versatile, extensive community support, and highly modular for custom solutions.\n",
       "- **Weaknesses:** Steep learning curve, potentially complex for simpler tasks, and overwhelming documentation.\n",
       "\n",
       "### AutoGen\n",
       "- **Strengths:** Excellent for multi-agent collaboration, flexible agent configurations, and strong performance backed by Microsoft.\n",
       "- **Weaknesses:** Primarily focused on conversational agents, might be overkill for single-agent tasks, and a relatively maturing ecosystem.\n",
       "\n",
       "### CrewAI\n",
       "- **Strengths:** Intuitive for defining agent roles and complex workflows, strong emphasis on task delegation, and promotes organized multi-agent systems.\n",
       "- **Weaknesses:** More specialized towards multi-agent collaboration, potentially less flexible for custom architectures, and a smaller but growing community.\n",
       "\n",
       "### LlamaIndex\n",
       "- **Strengths:** Exceptional for Retrieval Augmented Generation (RAG) and data-centric agents, simplifies interaction with varied data sources, and integrates well with other frameworks.\n",
       "- **Weaknesses:** Agentic capabilities are centered around data retrieval, not as broad for general-purpose or autonomous agent tasks.\n",
       "\n",
       "### SuperAGI\n",
       "- **Strengths:** Dedicated to autonomous, goal-oriented agents, offers a user interface for deployment and monitoring, and a strong focus on persistent memory and tool integration.\n",
       "- **Weaknesses:** Smaller community, less vast ecosystem of tools, and can be complex to debug without robust internal tooling.\n",
       "\n",
       "### Choosing the Right Framework\n",
       "The choice of framework depends on the specific requirements of the project:\n",
       "\n",
       "- **For General-Purpose LLM Applications:** LangChain might be the most versatile choice due to its modular nature and extensive community support.\n",
       "- **For Multi-Agent Collaboration:** AutoGen or CrewAI could be more suitable, depending on the complexity and specific needs of the collaboration.\n",
       "- **For Data-Centric Applications:** LlamaIndex is exceptional for tasks involving data retrieval and interaction.\n",
       "- **For Autonomous Agents:** SuperAGI offers dedicated capabilities for building and managing goal-oriented agents.\n",
       "\n",
       "Ultimately, the selection should be based on the project's specific needs, considering factors such as the complexity of the task, the desired level of autonomy, and the type of collaboration required among agents."
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "groq = OpenAI(api_key=groq_api_key, base_url=\"https://api.groq.com/openai/v1\")\n",
    "model_name = \"llama-3.3-70b-versatile\"\n",
    "\n",
    "response = groq.chat.completions.create(model=model_name, messages=messages)\n",
    "answer = response.choices[0].message.content\n",
    "\n",
    "display(Markdown(answer))\n",
    "teammates.append(model_name)\n",
    "answers.append(answer)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ff45b162",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
